<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var userStr2 = '{"name":"李四","age":30,"sex":"女"}';
        //把对象类型字符串转换为对象
        var user2 = JSON.parse(userStr2);
        console.log(user2.age);
    </script>
</body>

</html>